<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="lib/layui-v2.5.6/layui/css/layui.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>图片列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 图片管理 <span
        class="c-gray en">&gt;</span> 图片列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c"> 日期范围：
        <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin"
               class="input-text Wdate" style="width:120px;">
        -
        <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax"
               class="input-text Wdate" style="width:120px;">
        <input type="text" name="" id="" placeholder=" 图片名称" style="width:250px" class="input-text">
        <button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜图片</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"><a href="javascript:;" onclick="datadel()"
                                                               class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a
            class="btn btn-primary radius" onclick="picture_add('添加图片','picture-add.html')" href="javascript:;"><i
            class="Hui-iconfont">&#xe600;</i> 添加图片</a></span> <span class="r">共有数据：<strong>54</strong> 条</span></div>
    <div class="mt-20">
        <table id="pictureList" lay-filter="test"></table>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="lib/layui-v2.5.6/layui/layui.js"></script>
<script type="text/javascript">
    var layer;
    var pictureTable;
    $(document).ready(function () {
        layui.use(["layer", "table"], function () {
            layer = layui.layer;

            var table = layui.table;

            //第一个实例
            pictureTable = table.render({
                elem: '#pictureList'
                , url: '/Olala/picture/listPicture' //数据接口
                , page: true //开启分页
                , method: 'post'
                , response: {
                    statusCode: 20 //规定成功的状态码，默认：0
                }
                , cols: [
                    [ //表头
                        {field: "checkBox", type: "checkbox", width: '5%'}
                        , {field: "pictureId", title: '编号', width: '5%', sort: true}
                        , {field: 'picCategory', title: '分类', width: '5%'}
                        ,
                        {
                            field: 'originalImg', title: '封面', width: '35%',
                            templet: function (data) {
                                var url = data.originalImg;
                                return '<a href="http://localhost:8080' + url + '" target="_blank">' + url + '</a>'
                            }
                        }
                        , {field: 'pictureTitle', title: '图片名称', width: '5%'}
                        ,
                        {
                            field: 'relationType', title: '标签', width: '10%',
                            templet: function (data) {
                                switch (data.relationType) {
                                    case 0:
                                        return '商品';
                                    case 1:
                                        return '店铺';
                                    case 2:
                                        return '文章资讯';
                                    case 3:
                                        return '热门活动';
                                }
                            }

                        }
                        , {field: 'updateTime', title: '更新时间', width: '20%', sort: true}
                        ,
                        {
                            field: 'status', title: '是否启用', width: '10%', sort: true,
                            templet: function (data) {
                                return data.status === true ? '是' : '否';
                            }
                        }
                        ,
                        {
                            field: 'check', title: "审核", width: '5%',
                            templet: function (data) {
                                return '<button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="picture_charge(' + data.pictureId + ')">审核</button>';
                            }
                        }
                    ]
                ]
            });
        })
    });

    /*图片-添加*/
    function picture_add(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            end: function () {
                $.get('/Olala/picture/delImageCatch');
                pictureTable.reload();
            }
        });
        layer.full(index);
    }

    function picture_charge(id) {
        //审核
        var index = layer.confirm('启用？', {
            btn: ['是', '否', '取消'], //按钮
            end: function () {
                layer.msg("操作成功");
                pictureTable.reload();
            }
        }, function () {
            $.post('/Olala/picture/updateStatusById', {pictureId: id, status: true})
            layer.close(index);
        }, function () {
            $.post('/Olala/picture/updateStatusById', {pictureId: id, status: false})
            layer.close(index);
        });


    }


</script>
</body>
</html>